package cn.iocoder.yudao.module.promotion.groupon.dao;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.framework.business.interest.dao.InterestMapper;
import cn.iocoder.yudao.module.promotion.groupon.pojo.po.GrouponPackageFavorite;
import jakarta.annotation.Nullable;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Set;

@Mapper
public interface GrouponPackageFavoriteMapper extends InterestMapper<GrouponPackageFavorite> {

    @Override
    default GrouponPackageFavorite selectOneByBizIdAndUserId(Long bizId, Long userId, @Nullable Boolean recycled) {
        CoreLambdaQueryWrapper<GrouponPackageFavorite> wrapper = new CoreLambdaQueryWrapper<>();
        wrapper.eq(GrouponPackageFavorite::getPackageId, bizId);
        wrapper.eq(GrouponPackageFavorite::getUserId, userId);
        wrapper.eqIfPresent(GrouponPackageFavorite::getRecycled, recycled);
        wrapper.limitN(1);
        return selectOne(wrapper);
    }

    @Override
    default List<GrouponPackageFavorite> selectListByBizIdsAndUserId(Set<Long> bizIds, Long userId) {
        CoreLambdaQueryWrapper<GrouponPackageFavorite> wrapper = new CoreLambdaQueryWrapper<>();
        wrapper.inIfPresent(GrouponPackageFavorite::getPackageId, bizIds);
        wrapper.eq(GrouponPackageFavorite::getUserId, userId);
        return selectList(wrapper);
    }

}